package com.zzl.bonds.ticket.constant.status;

import com.zzl.bonds.ticket.constant.type.TicketTypeEnum;
import com.zzl.bonds.ticket.dto.KeyValue;

import java.util.ArrayList;
import java.util.LinkedList;
import java.util.List;

/**
 * @author : spp
 * @date : 2022/2/18 10:07
 */
public enum HandStatusEnum {

    /**
     * 开单待复核
     */
    ALL(1, "全部", ""),
    OPEN_ING(2, "开立中", ""),
    SUCCESS(3, "成功", ""),
    FAIL(4, "失败", "");

    private Integer code;
    private String name;
    private String description;

    HandStatusEnum(Integer code, String name, String description) {
        this.code = code;
        this.name = name;
        this.description = description;
    }

    /**
     * 业务类型
     *
     * @param type 1 开立中 2 转让中 3 融资中
     * @return 枚举值对象
     */
    public static List<KeyValue> getKvList(Integer type) {
        /*TODO*/
        List<KeyValue> keyValues = new ArrayList<>();
        for (HandStatusEnum statusEnum : HandStatusEnum.values()) {
            KeyValue kv = new KeyValue();
            kv.setKey(statusEnum.code);
            if (HandStatusEnum.OPEN_ING.getCode().equals(statusEnum.code)) {
                kv.setValue(TicketTypeEnum.getValue(type));
            } else {
                kv.setValue(statusEnum.name);
            }
            keyValues.add(kv);
        }
        return keyValues;
    }


    public Integer getCode() {
        return code;
    }

    public String getName() {
        return name;
    }

    public String getDescription() {
        return description;
    }
}
